/***************************************************************************
 *   Copyright (C) 2006 by Archimedes Projekt   *
 *   thelsb@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef HPSCEVENTTHREAD_H
#define HPSCEVENTTHREAD_H

#include <QThread>
#include <QMutex>
#include "hpsceventhandler.h"

/**
A threaded event class, to allow socket operations indipedndent of the GUI thread.
For example, some concurrent operations need sleep between them, and if this is done in the GUI thread the whole GUI thread sleeps.

	@author Archimedes Projekt <thelsb@gmail.com>
*/
class HPSCEventThread : public QThread
{
	Q_OBJECT
	friend class HPSCEventHandler;
	protected:
		QString m_host;
		quint32 m_port;
		QMutex m_socketMutex;
		HPSCEventHandler *m_eventHandler;
        QTimer *m_socketTimer; //checks if socket connection is alive
	private:
		HPSCEventThread(const HPSCEventThread &instance):QThread(){}
public:
	HPSCEventThread(QString host,quint32 port);
	HPSCEventHandler *eventHandler();
    ~HPSCEventThread();
	void run();
    
public slots:
   // void readSocket();
    signals:
        void sig_hpscDisconnected();

};

#endif
